import { http, type ResultList, type ResultBoolean } from "@/utils/http";

// 分页查询系统公告
export const getAnnouncementPage = (data?: object) => {
  return http.request<ResultList>("post", "/api/announcement/page", { data });
};

// 新增系统公告
export const createAnnouncement = (data: AnnouncementDTO) => {
  return http.request<ResultBoolean>("post", "/api/announcement/add", { data });
};

// 编辑系统公告
export const updateAnnouncement = (data: AnnouncementDTO) => {
  return http.request<ResultBoolean>("post", "/api/announcement/edit", {
    data
  });
};

// 删除系统公告
export const deleteAnnouncement = (id: number) => {
  return http.request<ResultBoolean>("post", `/api/announcement/delete/${id}`);
};

// 根据ID获取公告详情
export const getAnnouncementDetail = (id: number) => {
  return http.request<ResultList>("get", `/api/announcement/get/${id}`);
};

/**
 * 系统公告DTO接口定义
 */
export interface AnnouncementDTO {
  id?: number;
  title: string;
  content: string;
  isFeaturedOnHome: boolean;
  publishTime?: string;
}
